import request from '@/axios/request';

enum api {
    LOGIN_API = '/login/',
    USER_ACL_API = '/login/user_acl',
    refresh_token_API = '/login/refresh_token'
}

// 登录参数类型
export interface LoginParams {
    username: string;
    password: string;
}

interface bacetype {
    code: number;
    message: string;
    status: boolean;
}

interface tokentype {
    access_token: string;
    token_type: string;
    refresh_token: string;
    username: string;
    routes: string[]|[];
    buttons: string[]|[];
}

// 登录返回类型
export interface LoginResult extends bacetype {
   data: tokentype;
}



interface user_acl_type {
    routes:string[]|[],
    buttons:string[]|[]
}

// 用户权限信息返回类型
export interface UserInfoResult extends bacetype {
    data: user_acl_type
}

// 用户登录接口
export const loginAPI = (data: LoginParams) => {
    return request.post<any,LoginResult>(api.LOGIN_API, data);
}
    
// 刷新token

export function refreshToken() {
    return request.post<any,any>(api.refresh_token_API);
}


// 获取用户权限信息

export function getUseracl() {
    return request.get<any,UserInfoResult>(api.USER_ACL_API);
}
